﻿package addCompo.ub
{
	
	import flash.display.*;
	import flash.text.*;
	
	public dynamic class XMUniversalButtonPreview extends Sprite {

		private var _width:Number;
		private var _height:Number;

		public var avatar_mc:DisplayObject;
		public var label_txt:TextField;

		public function XMUniversalButtonPreview() {
			_width = super.width;
			_height = super.height;
			removeChild(avatar_mc);
			draw();
		}

		public function setSize(w:Number, h:Number):void {
			_width = w;
			_height = h;
			draw();
		}

		public override function get width():Number {
			return _width;
		}
		public override function set width(w:Number):void {
			setSize(w, height);
		}


		public override function get height():Number {
			return _height;
		}
		public override function set height(h:Number):void {
			setSize(width, h);
		}

		public function draw():void {
			graphics.clear();
			graphics.beginFill(0xEEEEEE, .8);
			graphics.drawRect(0, 0, _width, _height);
			graphics.endFill();
			graphics.lineStyle(1, 0x333333);
			graphics.drawRect(0, 0, _width, _height);
			
			// Try full name
			label_txt.width = _width - 6;
			label_txt.text = "";
			if (label_txt.numLines > 1) {
				label_txt.text = "";
				if (label_txt.numLines > 1) {
					label_txt.text = "";
				}
			}
			
			label_txt.text = "Default Skin";
			label_txt.x = Math.max(0, (_width -label_txt.width) >>1);
			label_txt.y = Math.max(0, (_height - label_txt.height) >>1);
		}
	}
}
